//
//  SettingViewController.m
//  duoduo
//
//  Created by wanghao on 16/10/12.
//  Copyright © 2016年 LX. All rights reserved.
//

#import "SettingViewController.h"
#import "LoginViewController.h"

@interface SettingViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    NSArray * titleArr;
}
@property (nonatomic,strong) UITableView * listTableView;


@end

@implementation SettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    titleArr = @[@"清除缓存",@"自检查更新",@"关于多多"];
    self.title = @"设置";
    [self initUI];
}

- (void)initUI
{

    _listTableView =[[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-5) style:UITableViewStylePlain];
    _listTableView.delegate = self;
    _listTableView.dataSource = self;
    _listTableView.backgroundColor = LXHexColor(0xF5F6F7);
    [self.view  addSubview:_listTableView];
    _listTableView.tableFooterView = [[UIView alloc]init];
    _listTableView.bounces = NO;

    self.view.backgroundColor = LXHexColor(0xF5F6F7);

    UIButton * button = [[UIButton alloc]init];
    button.frame = CGRectMake(25, ScreenHeight-150, ScreenWidth-50, 45);
    button.backgroundColor = LXHexColor(0x5DCA68);
    [button setTitle:@"退出当前账号" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:20];
    button.layer.cornerRadius = 6;
    button.layer.masksToBounds = YES;
    [button addTarget:self action:@selector(logoutClick) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:button];
    
}

- (void)logoutClick
{
    LoginViewController * loginVC = [[LoginViewController alloc]init];
    [self.navigationController pushViewController:loginVC animated:YES];
}

#pragma mark --- UITableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * cellID = @"listcell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"listcell"];
    if (!cell) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }

    [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];

    cell.textLabel.text = titleArr[indexPath.row];

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//    if (indexPath.section == 0) {
//        if (indexPath.row == 0) {
//            BAXDetailVC * order = [[BAXDetailVC alloc]init];
//            [self.navigationController pushViewController:order animated:YES];
//        }
//        if (indexPath.row == 1) {
//            DrivingOrderVC * driving = [[DrivingOrderVC alloc]init];
//            [self.navigationController pushViewController:driving animated:YES];
//        }
//    }else if (indexPath.section == 1) {
//        if (indexPath.row == 0) {
//            MyMoneyViewController * money = [[MyMoneyViewController alloc]init];
//            [self.navigationController pushViewController:money animated:YES];
//        }
//    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}


- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = NO;
    self.tabBarController.tabBar.hidden=YES;
}

@end
